using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;
using System.ComponentModel;

namespace Axe.Web.Controls
{
    public class LinkButtonSwitch : LinkButton
    {
        #region public bool Condition
        [DefaultValue(false)]
        [Category("Apperance")]
        [Bindable(true, BindingDirection.TwoWay)]
        public bool Condition
        {
            get
            {
                object o = ViewState["Condition"];
                if (o == null)
                    return false;

                return (bool)o;
            }
            set
            {
                ViewState["Condition"] = value;
            }
        }
        #endregion

        #region public string TrueText
        [DefaultValue("")]
        [Category("Apperance")]
        [Bindable(true, BindingDirection.TwoWay)]
        public string TrueText
        {
            get
            {
                object o = ViewState["TrueText"];
                if (o == null)
                    return "";

                return (string)o;
            }
            set { ViewState["TrueText"] = value; }
        } 
        #endregion

        #region public string FalseText
        [DefaultValue("")]
        [Category("Apperance")]
        [Bindable(true, BindingDirection.TwoWay)]
        public string FalseText
        {
            get
            {
                object o = ViewState["FalseText"];
                if (o == null)
                    return "";

                return (string)o;
            }
            set { ViewState["FalseText"] = value; }
        }
        #endregion

        #region public override string Text
        [Browsable(false)]
        [Bindable(true, BindingDirection.OneWay)]
        public override string Text
        {
            get
            {
                if (Condition)
                    return TrueText;
                else
                    return FalseText;
            }
        } 
        #endregion
    }
}
